package Test1;

import java.sql.SQLOutput;

public class Test1 {
//静态的泛型方法 需要在static后用 <> 声明泛型类型参数
    public static <E> void swap(E[] array,int i,int j){
        E t = array[i];
        array[i] = array[j];
        array[j] = t;
    }

        public static void main(String[] args) {
            MyArray<Integer> myArray1 = new MyArray<Integer>();
            myArray1.setArray(10,0);
            myArray1.setArray(12,1);
            //myArray1.setArray("aa",2);//自动类型检查
            Integer ret = myArray1.getArray(0);
            System.out.println(myArray1);

            MyArray<String> str = new MyArray<String>();
            str.setArray("shs",3);
            System.out.println(str);
        }

    public static void main3(String[] args) {
        Integer a = 127;
        Integer b = 127;

        Integer c = 128;
        Integer d = 128;

        System.out.println(a.equals(b));//true
        System.out.println(c.equals(d));//true

        System.out.println(a == b);//true（-128到127之间有缓存）
        System.out.println(c == d);//false
    }



    public static void main2(String[] args) {
        int i = 10;
        //装箱操作
        Integer ii = Integer.valueOf(i);//显式装箱
        Integer io = new Integer(i);//显式装箱
        Integer ia = 12;//自动装箱
        Integer is = i;//自动装箱
        Integer ib = (Integer) i;//自动装箱


        //拆箱操作
        int jv = ii.intValue();//显式拆箱
        int ja = ii;//自动拆箱
        int js = (int)ii;//自动拆箱
    }




    public static void func1(int N){
        int count = 0;
        for(int i = 0;i<N;i++){
            for(int j = 0;j<N;j++){
                count++;
            }
        }
        for(int k = 0;k<N*2;k++){
            count++;
        }
        int m = 10;
        while((m--)>0){
            count++;
        }
        System.out.println(count);
    }

    public static void main1(String[] args) {
        func1(2);
    }
}
